<?php


namespace App\Http\Controllers\Admin;


use App\Contracts\NotifyContracts;
use App\Events\OrderIsPay;
use App\Jobs\ProcessPodcast;
use App\Model\Admin;
use App\Model\Goods;
use App\Model\Order;
use App\Model\OrderMention;
use App\Model\Test;
use App\Service\Sms\SMSInterface;
use App\Tool\Json;
use App\Tool\NoticeType;
use Carbon\Carbon;
use Illuminate\Redis\Connections\PredisConnection;

class TestController extends \App\Http\Controllers\Weapp\Base
{


    function sql_test(NotifyContracts $notifyContracts,SMSInterface $sms)
    {


        $list=Goods::with('goods_sku')->with('goods_sku')->get()->toArray();

        dd($list);

//        return new \Exception('44');

//        $re=$sms->sendByTemplate('15827104268','','',[]);
//
//        dd($re);

//        request()->session()->flash('kk','gg');
//
//
//        var_dump(request()->session()->get('kk'));
//        var_dump(request()->session()->get('kk'));

//        dd(now()->gt((Carbon::parse('2020-7-4 11:12'))));
//        dd(now()->gt((Carbon::parse($d->start_time))));

//        var_dump($d->start_time);
//        dd(now());
//        dd(Carbon::parse('2020-7-4 9:50')->toDateTime());

//        event(new OrderIsPay(Order::find(21)));

//        event(new OrderIsPay());

//        NoticeType::order_is_pay_notice;


//        dd($sms->sendByTemplate(\Cache::get('order_setting:phone_list'),
//            \Cache::get('order_setting:sms_sign_name'),
//            \Cache::get('order_setting:order_is_pay_notice'),
//            ['product'=>'123456']
//        )->toArray());


//        $this->getUserInfo('1111');
//        dispatch(new ProcessPodcast('904801074@qq.com','123'));


//        $notifyContracts->send(Admin::find(240),'success');

//        $lock = \Cache::lock('snap_up' , 10);

//        $lock->block(10);
//
//
////        sleep(10);
//
//        $lock->release();
//        \Cache::lock('snap_up')->release();

//        return 111;

    }


    function test2(){

        //获取锁（锁定的时间为10秒）
        $lock = \Cache::lock('snap_up' , 10);

        //等待时长（最大十秒）
        $lock->block(10);

        //释放锁
        $lock->release();

        return 1111;

    }


    function rule_test(){


//        print_r(request()->route());


//        dd(\Route::getRoutes());

        $uri=[];
        foreach (\Route::getRoutes() as $v){




            $uri[]=$v->uri;

        }

        return Json::code(1,'success',$uri);
    }




}
